<?php
$cid=$_GET['c'];
$config=$this->config->item('img_size');
$noimg=$this->config->item('noimg');
$nocontent=$this->config->item('nocontent');
$nodown=$this->config->item('nodown');
$listseo=$this->config->item('listseo');
?>
<div class="btn-group">
    <a href="<?php echo site_urlc('product/index')?>" class='btn'> <i class="fa fa-arrow-left"></i> <?php echo lang('back_list')?></a>
</div>

<?php include_once 'inc_form_errors.php'; ?>

<div class="boxed">
    <h3> <i class="fa fa-pencil"></i> <span class="badge badge-success pull-right"><?php echo $title; ?></span> <?php echo lang('add') ?></h3>
    <?php echo form_open(current_urlc(),array("class"=>"form-horizontal","id"=>"frm-create")); ?>
    <div class="boxed-inner seamless">
        <div class="control-group">
            <label class="control-label" for="title"> <?php echo lang('title') ?> </label>
            <div class="controls">
                <input type="text" id="title" name="title" class='span7' value="<?php echo set_value("title") ?>">
            </div>
        </div>
        <?php if($cid==10):?>
        <div class="control-group">
            <label class="control-label" for="introduce"> 简介 </label>
            <div class="controls">
                <input type="text" id="introduce" name="introduce" class='span7' value="<?php echo set_value("introduce") ?>">
            </div>
        </div>
        <?php endif;?>
        <div class="control-group">
            <label class="control-label" for="borrow_price"> 借款金额 (万)</label>
            <div class="controls">
                <input type="text" id="borrow_price" name="borrow_price"  value="<?php echo set_value("borrow_price") ?>">
                <span class="help-inline">如：5~70 </span>
            </div>
        </div>
        <div class="control-group">
            <label class="control-label" for="deadline"> 期限范围 (月)</label>
            <div class="controls">
                <input type="text" id="deadline" name="deadline"  value="<?php echo set_value("deadline") ?>">
                <span class="help-inline">如：12~60 </span>
            </div>
        </div>
        <div class="control-group">
            <label class="control-label" for="credit"> 放款时间 (天)</label>
            <div class="controls">
                <input type="text" id="credit" name="credit"  value="<?php echo set_value("credit") ?>">
                <span class="help-inline">如：3~5 </span>
            </div>
        </div>
        <div class="control-group">
            <label class="control-label" for="min_interests"> 最低月利息</label>
            <div class="controls">
                <input type="text" id="min_interests" name="min_interests"  value="<?php echo set_value("min_interests") ?>">
                <span class="help-inline">% </span>
            </div>
        </div>
        <div class="control-group">
            <label class="control-label" for="max_interests"> 最高月利息</label>
            <div class="controls">
                <input type="text" id="max_interests" name="max_interests"  value="<?php echo set_value("max_interests") ?>">
                <span class="help-inline">% </span>
            </div>
        </div>
        <div class="control-group">
            <label class="control-label" for="repayment"> 还款方式</label>
            <div class="controls">
                <input type="text" id="repayment" name="repayment"  value="<?php echo set_value("repayment") ?>">
            </div>
        </div>
        <div class="control-group">
            <label class="control-label" for="virtual_num"> 申请成功人数</label>
            <div class="controls">
                <input type="text" id="virtual_num" name="virtual_num"  value="<?php echo set_value("virtual_num") ?>">
            </div>
        </div>
        <div class="control-group">
            <label for="title" class="control-label">时间:</label>
            <div class="controls">
                <div class="input-append date timepicker">
                    <input type="text" value="<?php echo date("Y-m-d H:i:s",set_value('timeline',now())); ?>" id="timeline" name="timeline" data-date-format="yyyy-mm-dd hh:ii:ss">
                    <span class="add-on"><i class="icon-th"></i></span>
                </div>
            </div>
        </div>

        <!-- ctype -->
        <?php if ($ctype = list_coltypes($this->cid)) { ?>
            <div class="control-group">
                <label class="control-label" for="status"> 所属分类:</label>
                <div class="controls">
                    <?php $ctypeid= isset($_GET['ctype']) ? $_GET['ctype'] : 0; ?>
                    <?php
                    echo ui_btn_select('ctype',set_value("ctype",$ctypeid),$ctype);
                    ?>
                    <span class="help-inline"></span>
                </div>
            </div>
        <?php } ?>



        <?php if(!in_array($cid, $nocontent)):?>
            <div class="tabbable">
                <ul class="nav nav-tabs">
                    <li class="active"><a href="#tab1" data-toggle="tab">申请条件</a></li>
                    <li><a href="#tab2" data-toggle="tab">所需材料</a></li>
                </ul>
                <div class="tab-content">
                    <div class="tab-pane active" id="tab1">
                        <div class="control-group uefull">
                            <textarea id="condition" name="condition"></textarea>
                            <span class="help-inline"></span>
                        </div>
                    </div>
                    <div class="tab-pane" id="tab2">
                        <div class="control-group uefull">
                            <textarea id="material" name="material"></textarea>
                            <span class="help-inline"></span>
                        </div>
                    </div>
                </div>
            </div>
        <?php endif;?>
        <?php if(!in_array($cid, $noimg)):?>
            <!-- 图片上传 -->
            <div class="control-group">
                <label for="img" class="control-label"><?php echo lang('photo') ?>：</label>
                <div class="controls">
                    <div class="btn-group">
                    <span class="btn btn-success">
                        <i class="fa fa-upload"></i>
                        <span><?php echo lang('upload_file');
                            if (isset($config[$cid])) {
                                echo '【建议大小' . $config[$cid] . '】';
                            } else {
                                echo '【未定义】';
                            } ?> </span>
                        <input class="fileupload" type="file"  accept="" multiple="">
                    </span>
                        <input type="hidden" name="photo" class="form-upload" data-more="1" value="<?php echo set_value("photo") ?>">
                        <input type="hidden" name="thumb" class="form-upload-thumb" value="">
                    </div>
                </div>
            </div>
            <div id="js-photo-show" class="js-img-list-f"></div>
            <div class="clear"></div>
            <!-- 图片上传 -->
        <?php endif;?>
        <!-- 图片上传 -->

    </div>

    <div class="boxed-footer">
        <?php if ($this->ccid): ?>
            <input type="hidden" name="ccid" value="<?php echo $this->ccid ?>">
        <?php endif ?>
        <input type="hidden" name="cid" value="<?php echo $this->cid ?>">
        <input type="submit" value=" <?php echo lang('submit'); ?> " class='btn btn-primary'>
        <input type="reset" value=' <?php echo lang('reset'); ?> ' class="btn btn-danger">
    </div>
    </form>
</div>

<?php include_once 'inc_ui_media.php'; ?>
<script type="text/javascript">
    require(['jquery','adminer/js/ui','adminer/js/media','bootstrap-datetimepicker.zh'],function($,ui,media){
        $('.timepicker').datetimepicker({'language':'zh-CN','format':'yyyy/mm/dd hh:ii:ss','todayHighlight':true});

        ui.editor_create('condition');
        ui.editor_create('material');
        media.init();
        var articles_photos = <?php echo json_encode(list_upload(set_value("photo"))) ?>;
        media.show(articles_photos,"photo");
        media.sort('photo');

    });
</script>
